home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Text⁄Files / Voyeur 1.1.1 / Voyeur ƒ / v code ƒ / v error.c < prev    next >
Text File  |  1994-02-26  |  2KB  |  84 lines

  1. /**********************************************************************\
  2.  
  3. File:        v error.c
  4.  
  5. Purpose:    This module handles displaying error messages specific to
  6.             Voyeur.
  7.  
  8.  
  9. Voyeur -- a no-frills file viewer
  10. Copyright ©1993-4, Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "v error.h"
  30. #include "program globals.h"
  31. #include "msg dialogs.h"
  32. #include "msg environment.h"
  33.  
  34. NMRec            gMyNotification;
  35. int                gPendingResultCode;
  36.  
  37. void HandleError(int resultCode)
  38. {
  39.     Str255            tempStr;
  40.     Handle            myResHand;
  41.     
  42.     if ((resultCode==userCancelErr) || (resultCode==allsWell)) return;
  43.     
  44.     gWhichFile=gLastFile;
  45.     if (gIsInBackground)
  46.     {
  47.         if (gHasNotificationManager)
  48.         {
  49.             myResHand=GetResource('SICN', 1234);
  50.             gMyNotification.qType=nmType;
  51.             gMyNotification.nmMark=1;
  52.             gMyNotification.nmIcon=myResHand;
  53.             gMyNotification.nmSound=(Handle)-1L;
  54.             gMyNotification.nmStr=0L;
  55.             gMyNotification.nmResp=0L;
  56.             gMyNotification.nmRefCon=0L;
  57.             NMInstall(&gMyNotification);
  58.         }
  59.         gPendingResultCode=resultCode;
  60.     }
  61.     else
  62.     {
  63.         GetIndString(tempStr, 129, resultCode);
  64.         ParamText(tempStr, "\p", "\p", "\p");
  65.         switch (resultCode)
  66.         {
  67.             case hexNotFoundErr:
  68.                 ParamText("\pThe hex value $", gFindHexString, "\p was not found (end of file reached.)","\p");
  69.                 PositionDialog('ALRT', prefsErrorAlert);
  70.                 StopAlert(prefsErrorAlert, 0L);
  71.                 break;
  72.             case asciiNotFoundErr:
  73.                 ParamText("\pThe text “",gFindString,"\p” was not found (end of file reached).","\p");
  74.                 PositionDialog('ALRT', prefsErrorAlert);
  75.                 StopAlert(prefsErrorAlert, 0L);
  76.                 break;
  77.             default:
  78.                 PositionDialog('ALRT', generalAlert);
  79.                 StopAlert(generalAlert, 0L);
  80.                 break;
  81.         }
  82.     }
  83. }
  84.